﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="AddTest.aspx.cs" Inherits="Business_Cisoft3G_UserManage3G_AddTest" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>添加管理员</title>
    <link href="../../../css/style.css" rel="stylesheet" type="text/css" />
    <link href="../../../css/font.css" rel="stylesheet" type="text/css" />
    <link href="../../../css/style_ts.css" rel="stylesheet" type="text/css" />

    <script type="text/javascript" src="../../../js/jquery-1.4.2.min.js"></script>

    <script language="javascript" type="text/javascript">


        function chktxtMemberName(obj) {
            var flag = false;
            var name = obj.value;
            if (isUsername(name) == 0) {
                $.get("UserIsExsistHandler.ashx?UserName=" + name,
                      function(data) {
                          if (data == "0") {
                              $('#divMessage').show();
                              $('#failinfo').html("<font style='color:#ffffff'>恭喜该用户名可以使用</font>");
                              flag = true;
                          }
                          if (data == "1") {
                              $('#divMessage').show();
                              $('#failinfo').text("该用户名已经存在！请更换后再试，比如" + name + new Date().getFullYear() + "");
                              flag = false;
                          }
                      });
            }
            else {
                flag = false;
            }
            return flag;
        }

        function isUsername(userName) {
            var reg_re = new RegExp("[!@#$%\\^&\\*\\(\\)]", "gi");
            var reg_space = new RegExp("[\\s]", "gi");
            var reg_length = new RegExp("^.{6,18}$", "gi");
            var reg_start = new RegExp("^[\\w_]*$", "gi");
            var reg_validate = new RegExp("^([a-z]|[A-Z])[0-9a-zA-Z_]{5,20}$", "g");
            var err = "";
            while ((arr = reg_re.exec(userName)) != null)
                err += arr;
            //            if (err != "") {
            //                //alert("-1");
            //                changeUsernamePrompt("用户名不能含有" + err.replace(/&/g, "&amp;"));
            //                return 1;
            //            } else if (reg_space.test(userName)) {
            //                changeUsernamePrompt("用户名不能含有空格");
            //                return 1;
            //            }
            //            if (!reg_length.test(userName)) {
            //                return 3;
            //            }
            //            if (!reg_start.test(userName)) {
            //                return 1;
            //            }
            //            if (!reg_validate.test(userName)) {
            //                return 2;
            //            }
            if (err != "") {
                //alert("-1");
                $('#divMessage').show();
                $('#failinfo').text("用户名不能含有" + err.replace(/&/g, "&amp;"));
                return;
            } else if (reg_space.test(userName)) {
                $('#divMessage').show();
                $('#failinfo').text("用户名不能含有空格");
                return;
            }
            //            if (!reg_length.test(userName)) {
            //                $('#divMessage').show();
            //                $('#failinfo').text("用户名长度必须为6到18个字符");
            //                return;
            //            }
            //            if (!reg_start.test(userName)) {
            //                $('#divMessage').show();
            //                $('#failinfo').text("用户名必须以字母开头");
            //                return;
            //            }
            else if ($.trim(userName)=='') {
                $('#divMessage').show();
                $('#failinfo').text("用户名不能为空");
                return;
            }
            else if (!reg_validate.test(userName)) {
                $('#divMessage').show();
                $('#failinfo').text("非法的用户名");
                return;
            }
            return 0;
        }

        function changeUsernamePrompt(cnt) {
            document.getElementById("divMessage").style.display = "";
            //document.getElementById( "divRecommandName" ).style.display="none";
            document.getElementById("failinfo").innerHTML = cnt;
        }

        function changeUserPwdPrompt(cntforpwd) {
            document.getElementById("divMessageforpwd").style.display = "";
            //document.getElementById( "divRecommandName" ).style.display="none";
            document.getElementById("failinfoforpwd").innerHTML = cntforpwd;
        }


        //密码检测
        function chkpwd(obj) {

            var Bobj = document.getElementById("chkResult");

            Bobj.innerHTML = "&nbsp;";
            var t = obj.value;
            //document.getElementById( "errspan1forpwd" ).className = "";

            changeUserPwdPrompt("&nbsp;");
            if (t == "" || t == null) {
                document.getElementById("pwdBox").style.borderColor = 'red';
                changeUserPwdPrompt("请输入密码");
                //document.getElementById("errspan1forpwd").className='error';
                return false;
            }

            var id = getResult(t);


            if (id == 0) {
                document.getElementById("pwdBox").style.borderColor = 'red';

                //document.getElementById("errspan1forpwd").className='error';
                changeUserPwdPrompt(document.getElementById("errspan1forpwd").innerHTML);
                return false;
            }
            else {
                //定义对应的消息提示
                var msg = new Array(4);
                msg[0] = "密码过短。";
                msg[1] = "密码强度差。";
                msg[2] = "密码强度良好。";
                msg[3] = "密码强度高。";

                var sty = new Array(4);
                sty[0] = -45;
                sty[1] = -30;
                sty[2] = -15;
                sty[3] = 0;

                var col = new Array(4);
                col[0] = "red";
                //col[1] = "gray";
                col[1] = "ffffff";
                //col[2] = "#ff6600";
                col[2] = "#ffffff";
                col[3] = "Green";

                //设置显示效果
                var sWidth = 300;
                var sHeight = 15;

                Bobj.style.fontSize = "12px";
                Bobj.style.color = col[id];
                Bobj.style.width = sWidth + "px";
                Bobj.style.height = sHeight + "px";
                Bobj.style.lineHeight = sHeight + "px";
                Bobj.style.textIndent = "20px";
                Bobj.innerHTML = "检测提示：" + msg[id];
            }
            return true;
        }

        //定义检测函数,返回0/1/2/3分别代表无效/差/一般/强
        function getResult(s) {

            if (s.length < 6 && s.length > 0) {
                return 0;
            }
            var ls = 0;
            if (s.match(/[a-z]/ig)) {
                ls++;
            }
            if (s.match(/[0-9]/ig)) {
                ls++;
            }
            if (s.match(/(.[^a-z0-9])/ig)) {
                ls++;
            }
            if (s.length < 6 && ls > 0) {
                ls--;
            }
            return ls
        }




        //确认密码检测
        function chkpwds(obj) {
            var strpwds = obj.value;
            var strpwd = document.getElementById("pwdBox").value;

            document.getElementById("errspan1forpwds").className = "";

            changeUserPwdsPrompt("&nbsp;");
            if (strpwds == "" || strpwds == null) {
                document.getElementById("pwdsBox").style.borderColor = 'red';
                changeUserPwdsPrompt("请输入确认密码");
                document.getElementById("errspan1forpwds").className = 'error';
                return false;
            }

            if (strpwds != strpwd) {
                document.getElementById("pwdsBox").style.borderColor = 'red';
                changeUserPwdsPrompt(document.getElementById("errspan1forpwds").innerHTML);
                document.getElementById("errspan1forpwds").className = 'error';
                return false;
            }
            return true;
        }
        function changeUserPwdsPrompt(strforpwds) {
            document.getElementById("divMessageforpwds").style.display = "";

            document.getElementById("failinfoforpwds").innerHTML = strforpwds;
        }






        //确认用户真实姓名
        function chktxtRealName(obj) {
            var strrealname = obj.value;
            document.getElementById("errspan1forrealname").className = "";

            changerealnamePrompt("&nbsp;");
            if (strrealname == "" || strrealname == null) {
                document.getElementById("txtRealName").style.borderColor = 'red';
                changerealnamePrompt(document.getElementById("errspan1forrealname").innerHTML);
                document.getElementById("errspan1forrealname").className = 'error';
                return false;
            }
            return true;

        }
        function changerealnamePrompt(strforrealname) {
            document.getElementById("divMessageforrealname").style.display = "";
            document.getElementById("failinfoforrealname").innerHTML = strforrealname;
        }


        function fLen(Obj) {
            var nCNLenth = 0;
            var nLenth = Obj.length;
            for (var i = 0; i < nLenth; i++) {
                if (Obj.charCodeAt(i) > 255) {
                    nCNLenth += 2;
                } else {
                    nCNLenth++;
                }
            }
            return nCNLenth;
        }


        //验证手机号码
        function checkPhone(obj) {
            var flag = false;
            var mobile = obj.value;
            if ($.trim(mobile) == '') {
                $('#lblPhone').text("请输入手机号码");
                flag = false;
            }
            else {
                var reg = /\d{11}/;
                if (reg.test(mobile)) {
                    $('#lblPhone').text("");
                    //                    return true;
                    $.get("UserIsExsistHandler.ashx?Mobile=" + mobile,
                      function(data) {
                          if (data == "0") {
                              flag = true;
                          }
                          if (data == "1") {
                              $('#lblPhone').text("该手机号码已经存在！");
                              flag = false;
                          }
                      });
                }
                else {
                    $('#lblPhone').text("请输入正确的手机号码");
                    flag = false;
                }
            }
            return flag;
        }



        //终验
        function zongcheck() {
            //    document.getElementById( "divMessageforvalicode2" ).innerHtml = "&nbsp;";
            var zongcheckforall = true;
            zongcheckforall = chktxtMemberName(document.getElementById("txtMemberNameforregiester"));

            if (!zongcheckforall) {
                return zongcheckforall;
            }
            zongcheckforall = chkpwd(document.getElementById("pwdBox"));

            if (!zongcheckforall) {
                return zongcheckforall;
            }

            zongcheckforall = chkpwds(document.getElementById("pwdsBox"));

            if (!zongcheckforall) {
                return zongcheckforall;
            }
            zongcheckforall = chktxtRealName(document.getElementById("txtRealName"));

            if (!zongcheckforall) {
                return zongcheckforall;
            }
            zongcheckforall = checkPhone(document.getElementById('txtPhone'));
            if (!zongcheckforall) {
                return zongcheckforall;
            }
            return zongcheckforall;
        }
    </script>

    <style type="text/css">
        .modalBackground
        {
            background-color: Gray;
            filter: alpha(opacity=70);
            opacity: 0.7;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="Scriptmanager1" runat="server" EnableScriptGlobalization="true"
        EnableScriptLocalization="true">
    </asp:ScriptManager>
    <!--第一行-->
    <div class="position_list">
        <div class="position_left_list">
        </div>
        <div class="position_con_list">
            <table border="0" cellpadding="0" cellspacing="0">
                <tr>
                    <td width="30">
                        <img src="../../../Images/3G/icon21.gif" width="14" height="14" alt="" />
                    </td>
                    <td class="cyan12">
                        新增管理员
                    </td>
                </tr>
            </table>
        </div>
        <div class="position_right_list">
        </div>
    </div>
    <!--系统温馨提示栏-->
    <div class="search_list">
        <div class="search_top_list">
            <div class="search_topleft_list">
            </div>
            <!--  查询     -->
            <div class="search_topbg_list">
                <table border="0" cellpadding="0" cellspacing="0">
                    <tr>
                        <td width="30" align="left" valign="middle" style="padding-top: 4px;">
                            <img src="../../../Images/3G/icon_logo.gif" width="22" height="22" />
                        </td>
                        <td width="100" class="cyan13_bold" style="padding-top: 5px;">
                            系统温馨提示栏
                        </td>
                        <td style="padding-top: 5px;">
                            &nbsp;&nbsp;&nbsp;
                        </td>
                    </tr>
                </table>
            </div>
            <div class="search_topright_list">
            </div>
        </div>
    </div>
    <!--   查询条件    -->
    <div class="index_search_con_list">
        <!--会员注册账号密码信息-->
        <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="73798f" id="table1"
            class="white12_normal" style="padding-left: 10px;">
            <!--会员注册名-->
            <tr bgcolor="#1E3541">
                <td width="120" valign="middle" style="text-align: right;">
                    <span style="color: Red">*</span>登录名：
                </td>
                <td width="300" valign="middle" style="text-align: left; padding-left: 10px;">
                    <asp:TextBox ID="txtMemberNameforregiester" runat="server" Width="100%" MaxLength="20"
                        onfocus="this.style.borderColor='#000000'" onblur="this.style.borderColor='#A3BFA8';chktxtMemberName(this);"></asp:TextBox>
                    <div id="divMessageforloginnameservice" runat="server">
                    </div>
                    <div id="service" style="behavior: url(webservice.htc)">
                    </div>
                    <div id="divMessage" style="display: none">
                        <span id="failinfo" style="color: Red"></span>
                    </div>
                </td>
                <td class="rightforregister" class="cyan12">
                    <span id="errspan1" class="cyan12">&nbsp;&nbsp;&nbsp;&nbsp;用户名只能由英文字母a～z(不区分大小写)、数字0～9、下划线组成。</span><br />
                    <span id="errspan2" class="cyan12">&nbsp;&nbsp;&nbsp;&nbsp;用户名的起始字符必须是英文字母。如：netease_2005
                    </span>
                    <br />
                    <span id="errspan3" class="cyan12">&nbsp;&nbsp;&nbsp;&nbsp;用户名长度为5～20个字符。</span><br />
                </td>
            </tr>
            <!--会员名检测结果-->
            <%-- <tr height="20px">
                <td class="leftforregister">
                </td>
                <td class="jyjgforregister" colspan="2">
                    <div id="divMessage" style="display: none">
                        <span id="failinfo"></span>
                    </div>
                </td>
            </tr>--%>
            <!--密码-->
            <tr bgcolor="#1E3541" style="height: 30px;">
                <td width="120" valign="middle" style="text-align: right;">
                    <span style="color: Red">*</span>密码：
                </td>
                <td width="300" valign="middle" style="text-align: left; padding-left: 10px;">
                    <asp:TextBox ID="pwdBox" runat="server" Width="100%" MaxLength="18" TextMode="Password"
                        Style="border: 1px solid #ffffff;" onfocus="this.style.borderColor='#000000'"
                        onblur=" this.style.borderColor='#A3BFA8';chkpwd(this);"></asp:TextBox>
                    <div id="divMessageforpwd" style="display: none">
                        <span id="failinfoforpwd" style="color: Red"></span>
                    </div>
                    <span id="chkResult" style="color: Red"></span>
                </td>
                <td class="cyan12">
                    <span id="errspan1forpwd">&nbsp;&nbsp;&nbsp;&nbsp;密码长度6～18位，由英文字母a～z (区分大小写)，数字0～9，特殊字符组成。</span><br />
                </td>
            </tr>
            <!--密码检测结果-->
            <%--<tr height="20px">
                <td class="leftforregister">
                </td>
                <td class="jyjgforregister" colspan="2">
                    <div id="divMessageforpwd" style="display: none">
                        <span id="failinfoforpwd"></span>
                    </div>
                    <span id="chkResult"></span>
                </td>
            </tr>--%>
            <!--确认密码-->
            <tr bgcolor="#1E3541" style="height: 30px;">
                <td width="120" valign="middle" style="text-align: right;">
                    <span style="color: Red">*</span>确认密码：
                </td>
                <td width="300" valign="middle" style="text-align: left; padding-left: 10px;">
                    <asp:TextBox ID="pwdsBox" runat="server" Width="100%" TextMode="Password" MaxLength="20" Style="border: 1px solid #ffffff;"
                        onblur=" this.style.borderColor='#A3BFA8';chkpwds(this);"></asp:TextBox>
                    <div id="divMessageforpwds" style="display: none">
                        <span id="failinfoforpwds" style="color: Red"></span>
                    </div>
                </td>
                <td class="cyan12">
                    <span id="errspan1forpwds">&nbsp;&nbsp;&nbsp;&nbsp;确认密码应与密码一致。</span><br />
                </td>
            </tr>
            <!--密码检测结果-->
            <%--<tr height="20px">
                <td class="leftforregister">
                </td>
                <td class="jyjgforregister" colspan="2">
                    <div id="divMessageforpwds" style="display: none">
                        <span id="failinfoforpwds"></span>
                    </div>
                </td>
            </tr>--%>
            <!--所属组名称-->
            <tr bgcolor="#1E3541" style="height: 30px;">
                <td width="120" valign="middle" style="text-align: right;">
                    <span style="color: Red">*</span>请选择角色：
                </td>
                <td width="300" valign="middle" style="text-align: left; padding-left: 10px;">
                    <asp:DropDownList ID="ddlUserGroupParent" runat="server">
                    </asp:DropDownList>
                </td>
                <td class="cyan12">
                    <span id="Span1">&nbsp;&nbsp;&nbsp;&nbsp;请选择角色</span><br />
                </td>
            </tr>
            <%-- <tr height="20px">
                <td class="leftforregister">
                </td>
                <td class="jyjgforregister" colspan="2">
                    <div style="display: none">
                        <span></span>
                    </div>
                </td>
            </tr>--%>
            <tr style="display: none">
                <td class="leftforregister" width="120" valign="middle" style="text-align: right;">
                    请选择所属部门：
                </td>
                <td style="text-align: left">
                    <asp:DropDownList ID="ddl_Unit" runat="server">
                    </asp:DropDownList>
                </td>
                <td class="rightforregister" class="cyan12">
                    <span id="Span4" runat="server">请选择所属部门</span><br />
                </td>
            </tr>
            <tr height="20px" style="display: none">
                <td class="leftforregister">
                </td>
                <td class="jyjgforregister" colspan="2">
                    <div style="display: none">
                        <span></span>
                    </div>
                </td>
            </tr>
            <!--真实姓名-->
            <tr bgcolor="#1E3541" style="height: 30px;">
                <td width="120" valign="middle" style="text-align: right;">
                    <span style="color: Red">*</span>真实姓名：
                </td>
                <td width="300" valign="middle" style="text-align: left; padding-left: 10px;">
                    <asp:TextBox ID="txtRealName" runat="server" Width="100%" MaxLength="4" Style="border: 1px solid #ffffff;"
                        onfocus="this.style.borderColor='#000000'" onblur="this.style.borderColor='#A3BFA8';chktxtRealName(this);"></asp:TextBox>
                    <div id="divMessageforrealname" style="display: none;">
                        <span id="failinfoforrealname" style="color: Red"></span>
                    </div>
                </td>
                <td class="cyan12">
                    &nbsp;&nbsp;&nbsp;&nbsp;<span id="errspan1forrealname">请填写真实姓名。</span><br />
                </td>
            </tr>
            <!--真实姓名检测结果-->
            <%-- <tr height="20px">
                <td class="leftforregister">
                </td>
                <td class="jyjgforregister" colspan="2">
                    
                </td>
            </tr>--%>
            <!--电话-->
            <tr bgcolor="#1E3541" style="height: 30px;">
                <td width="120" valign="middle" style="text-align: right;">
                    <span style="color: Red">*</span>手机号码：
                </td>
                <td width="300" valign="middle" style="text-align: left; padding-left: 10px;">
                    <asp:TextBox ID="txtPhone" runat="server" Width="100%" MaxLength="11" Style="border: 1px solid #ffffff;"
                        onfocus="this.style.borderColor='#000000'" onblur="this.style.borderColor='#A3BFA8';checkPhone(this);"></asp:TextBox>
                    <%--<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                        ErrorMessage="请输入手机号码" ControlToValidate="txtPhone" Display="Dynamic"></asp:RequiredFieldValidator>--%>
                    <asp:Label ID="lblPhone" runat="server" Style="color: Red"></asp:Label>
                </td>
                <td class="rightforregister" class="cyan12">
                    <span id="Span3" class="cyan12">&nbsp;&nbsp;&nbsp;&nbsp;请填写手机号码。</span><br />
                </td>
            </tr>
            <!--手机检测结果-->
            <%--            <tr height="20px">
                <td class="leftforregister">
                </td>
                <td class="jyjgforregister" colspan="2">
                    
                </td>
            </tr>--%>
            <%--按钮提交--%>
            <tr bgcolor="#1E3541" style="height: 30px;">
                <td width="120" valign="middle" style="text-align: right;">
                </td>
                <td width="300" valign="middle" style="text-align: left; padding-left: 10px;">
                    <asp:Button ID="btnAdd" runat="server" Text="" ToolTip="添加" OnClick="ibtnadd_Click" OnClientClick="return zongcheck()"/>
                    <asp:Button ID="btnBack" runat="server" Text="" ToolTip="返回" OnClick="ibtnback_Click"
                        CausesValidation="false" Visible="false" />
                    <input type="button" id="btnBack" onclick="window.location.href='UserManage3G.aspx'"></input>
                </td>
                <td class="rightforregister">
                </td>
            </tr>
        </table>
        <!--会员注册详细资料-->
        <table cellpadding="0" cellspacing="0" border="0" width="800px" style="display: none">
            <!--职位-->
            <tr style="display: none">
                <td class="leftforregister">
                    职位：
                </td>
                <td class="centerforregister">
                    <asp:TextBox ID="txtJoblName" runat="server" Width="184px" MaxLength="20" onfocus="this.style.borderColor='#000000'"
                        onblur="this.style.borderColor='#A3BFA8';" Text="管理员"></asp:TextBox>
                </td>
                <td class="rightforregister">
                    <span id="Span2">请填写职位。</span><br />
                </td>
            </tr>
            <!--职位检测结果-->
            <tr height="20px" style="display: none">
                <td class="leftforregister">
                </td>
                <td class="jyjgforregister" colspan="2">
                    <%--<asp:RequiredFieldValidator ID="RequirestyleLabeltxtJoblName" runat="server" ControlToValidate="txtJoblName"
                        Display="Dynamic" ErrorMessage="<span class=reshow>请填写职位名称</span>"></asp:RequiredFieldValidator>--%>
                </td>
            </tr>
        </table>
    </div>
    <div class="search_bottom_list">
        <div class="search_bottomleft_list">
        </div>
        <div class="search_bottombg_list">
        </div>
        <div class="search_bottomright_list">
        </div>
    </div>
    <ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender2" runat="server" TargetControlID="LinkButton1"
        PopupControlID="Panel1" BackgroundCssClass="modalBackground" OnOkScript="onOk()"
        DropShadow="false" PopupDragHandleControlID="Panel2" CancelControlID="btnCloseAll2">
    </ajaxToolkit:ModalPopupExtender>
    <asp:Panel ID="Panel1" runat="server" Style="display: none; width: 26%;
        vertical-align: middle;">
        <div class="attention_delete">
            <asp:Panel ID="Panel2" runat="server" Style="vertical-align: middle;">
                <div class="attention_top">
                    <div class="attention_topleft">
                    </div>
                    <div class="attention_topmid_delete">
                        <table width="98%" border="0" cellpadding="0" cellspacing="0">
                            <tr>
                                <td align="left" valign="middle" class="title">
                                    提示信息
                                </td>
                                <td align="right" valign="middle" width="30">
                                    <asp:Button ID="btnCloseAll2" runat="server" Text="" />
                                </td>
                            </tr>
                        </table>
                    </div>
                    <div class="attention_topright">
                    </div>
                </div>
            </asp:Panel>
            <div class="attention_con">
                <asp:Panel ID="Panel3" runat="server">
                    <table border="1" runat="server" id="table2" cellpadding="5" cellspacing="0" bordercolor="#0e62a7"
                        style="width: 100%; text-align: center; border-collapse: collapse;">
                        <tr>
                            <td style="text-align: Center">
                                <asp:Label ID="lblTS" runat="server" Text=""></asp:Label>
                                <asp:Button ID="btnBack_ts" runat="server" ToolTip="返回列表页" Visible="false"/>
                            </td>
                        </tr>
                    </table>
                </asp:Panel>
            </div>
        </div>
    </asp:Panel>
    <asp:LinkButton ID="LinkButton1" runat="server"></asp:LinkButton>
    
    </form>
</body>
</html>
